package com.liuy.util.shell;

import java.util.Iterator;
import java.util.List;

import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.configuration.XMLConfiguration;

import com.liuy.util.mail.MailSenderInfo;


/**
 * 从XML中读取相应的信息
 * 
 * */
public class ReadCmdFromXML {
	
	
	
   /**
    * 从XML信息里读取要执行的命令
    * 
    * */		
	public static List<String> getCmdLines(){    
		   
		XMLConfiguration config = null;
		try {			
			config = new XMLConfiguration("shellCMDconfig.xml");
		}catch (ConfigurationException e) {
			e.printStackTrace();
		}
			
		if(config == null ){
			return null;     
		}else{			
			List <String> cmdlines =config.getList("cmd");
			//将内容打出
			//Iterator<String> cms =  cmdlines.iterator();
			//while(cms.hasNext()){
			//	System.out.println("命令行为 "+cms.next());
			//}			
			return cmdlines ;		     
		}    	
	}    
	
	
	/**
	 * 从XML信息里读取要存储路径
	 * 
	 * */
	public static String getXMLContent(String xmlname){   
		
		XMLConfiguration config = null;
		try {			
			config = new XMLConfiguration("shellCMDconfig.xml");
		}catch (ConfigurationException e) {
			e.printStackTrace();
		}
			
		if(config == null ){
			return null;     
		}else{			
			String XmlContent = config.getString(xmlname);		
			return XmlContent ;		     
		}  
		
	}
	
}	   


